home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Games / Starter / JST / Developer / sources / src / loaders / Blastar / blastarhd.asm < prev    next >
Encoding:
Assembly Source File  |  1999-12-03  |  3.3 KB  |  174 lines

  1. ; *** Blastar Hard Disk Loader V$VER
  2. ; *** Written by Jean-François Fabre
  3.  
  4.  
  5.     include    "jst.i"
  6.  
  7. ;               disk        disk    number
  8. ;               image    size      of
  9. ;               name        (DOS)    disks
  10. ;                |          |      |
  11.     HD_PARAMS    "Blastar.d",STD_DISK_SIZE,3
  12.  
  13. _loader:
  14.     move.l    #$80000,D0    ; 512K
  15.     JSRABS    AllocExtMem    ; allocates the extra 512K which the game needs
  16.     RELOC_MOVEL    D0,ExtBase    ; stores it (relocated macro)
  17.     beq    MemErr            ; 0 > no mem!
  18.  
  19.     Mac_printf    "Blastar JST HD Loader V1.2"
  20.     Mac_printf    "Programmed by Jean-François Fabre © 1997"
  21.  
  22.     JSRABS    LoadDisks    ; loads disk data (except if LOWMEM is on)
  23.                 ; if HDLOAD is on, load only first disk
  24.  
  25.     moveq.l    #0,D0
  26.     move.l    #CACRF_CopyBack,D1    ; disable copyback cache
  27.     JSRABS    Degrade            ; set display to PAL (unless NTSC is on)
  28.  
  29. ;    WAIT_LMB            ; enable it and you can break here using HRTMon
  30.  
  31.     GO_SUPERVISOR            ; supervisor mode (macro)
  32.     SAVE_OSDATA    $80000        ; saves 0->$80000 (it will be overwritten by game)
  33.  
  34.     ; **** boot stuff and patch
  35.  
  36.     bsr    loadboot        ; loads the boot program
  37.  
  38.     JSRGEN    InitTrackDisk        ; trackdisk emulation
  39.     
  40.     PATCHUSRJMP    $6004A,PatchLoader1    ; sets a patch
  41.  
  42.     JSRGEN    FlushCachesHard        ; caches flush
  43.     JMP    $60000            ; jump!
  44.  
  45.  
  46. PatchLoader1:
  47.     JSRGEN    TrackLoad
  48.  
  49.     PATCHGENJMP    $7EBB0,RNCDecrunch    ; faster decrunch (the game uses RNC)
  50.     PATCHUSRJMP    $7EADE,GetExtMem    ; emulates search for extra mem
  51.     PATCHUSRJMP    $7E362,ReadSectors    ; read sectors (RobNorthen routine)
  52.     PATCHUSRJMP    $7EB8A,PatchProg    ; another patch
  53.  
  54.     JSRGEN    FlushCachesHard            ; caches flush (we just patched)
  55.  
  56.     jmp    $7A000                ; game again
  57.  
  58. PatchProg:
  59.     move.l    ExtBase(pc),A0            ; get extension pointer in A0
  60.     STORE_REGS                ; save registers
  61.  
  62.     ; *** disk load routine
  63.  
  64.     move.l    A0,A1
  65.     add.l    #$2D5D2,A1
  66.     move.w    #$4EF9,(A1)+
  67.     GETUSRADDR    ReadSectors
  68.     move.l    D0,(A1)
  69.  
  70. ;    move.l    A0,A1
  71. ;    add.l    #$2686A,A1
  72. ;    move.w    #$4EF9,(A1)+
  73. ;    GETGENADDR    RNCDecrunch
  74. ;    move.l    D0,(A1)
  75.  
  76.     ; *** keyboard interrupt
  77.  
  78.     move.l    A0,A1
  79.     add.l    #$9514,A1
  80.     move.w    #$4EB9,(A1)+
  81.     GETUSRADDR    kbint
  82.     move.l    D0,(A1)
  83.  
  84.     ; *** activates trainer keys
  85.  
  86.     move.l    A0,A1
  87.     add.l    #$95F8,A1
  88.     move.l    #$4E714E71,(A1)
  89.  
  90.     ; *** removes a patch for traps $64->$7C
  91.  
  92.     move.w    #$6010,$1AC(A0)
  93.  
  94.     ; *** patch to avoid the game to crash (protection??)
  95.  
  96.     move.l    A0,A1
  97.     add.l    #$191D0,A1
  98.     move.w    #$6004,(A1)
  99.     move.l    A0,A1
  100.     add.l    #$3DC42,A1
  101.     move.w    #$6004,(A1)
  102.  
  103.     ; *** copylock emulation
  104.  
  105.     move.l    A0,A1
  106.     add.l    #$2B6B6,A1
  107.     GETUSRADDR    copylockemu
  108.     move.l    D0,(A1)
  109.  
  110.     JSRGEN    FlushCachesHard        ; cache flush
  111.  
  112.     RESTORE_REGS
  113.     jmp    (A0)            ; jump to extension mem
  114.  
  115. copylockemu:
  116.     move.l    #$5EE0F501,$F4.W    ; copylock sets this value in $F4
  117.     rts
  118.  
  119. kbint:
  120.     move.b    $BFEC01,D0        ; SERDAT
  121.     move.l    D0,-(sp)
  122.  
  123.     ror.b    #1,D0
  124.     not.b    D0
  125.     cmp.b    #$5F,D0            ; HELP key?
  126.     bne    noquit$
  127.     JSRGEN    InGameExit        ; clean exit to WB
  128. noquit$
  129.  
  130.     move.l    (sp)+,D0
  131.     rts                ; return to game
  132.     
  133. ReadSectors:
  134.     JSRGEN    ReadRobSectors        ; standard RobNorthen load routine
  135.     moveq.l    #0,D0
  136.     rts
  137.  
  138.  
  139. GetExtMem:
  140.     move.l    ExtBase(pc),A0
  141.     move.l    A0,$7EBAA
  142.     rts
  143.  
  144. loadboot:
  145.     moveq.l    #0,D0
  146.     LEA    $60000,A0
  147.     move.l    #$F4,D1    ; length
  148.     move.l    #$32,D2    ; offset
  149.     JSRGEN    ReadDiskPart
  150.     tst.l    D0
  151.     bne    nodisk$
  152.     rts
  153.  
  154. nodisk$
  155.     lea    DiskErr(pc),A0
  156.     JSRGEN    SetExitRoutine    ; DiskErr called on quit, now.
  157.     JSRGEN    InGameExit
  158.     bra    nodisk$
  159.  
  160. trainer:
  161.     dc.l    0
  162. ExtBase:
  163.     dc.l    0
  164.  
  165. MemErr:
  166.     Mac_printf    "** Not enough memory to run Blastar"
  167.     JMPABS    CloseAll
  168.  
  169. DiskErr:
  170.     Mac_printf    "** Disk 1 missing!!!"
  171.     Mac_printf    "   Hit RETURN"
  172.     JSRABS    WaitReturn            ; waits for return in the output console
  173.     rts
  174.